/*
 * @Descripttion: 
 * @version: 
 * @Author: hollow
 * @Date: 2021-03-24 14:19:52
 * @LastEditors: sueRimn
 * @LastEditTime: 2021-03-25 17:35:00
 */
import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    list: [],
  },
  mutations: {
    Data(state, payload) {
      state.list = payload
    },
    del(state, payload) {
      state.list.forEach((item, index) => {
        if (item.id === payload) {
          state.list.splice(item, 1)
        }
      })
    },
    addpush(state, payload) {
      console.log(payload)
    },
    find(state, payload) {
      state.list = state.list.filter(item => item.name.includes(payload))
    },
    xuan(state, payload) {
      state.list = state.list.filter(item => item.price >= 50 && item.price <= 100)
    },
  },
  actions: {
    H_data(store) {
      axios.post('/list').then((res) => {
        store.commit('Data', res.data.data.data)
      })
    },

  },
  modules: {
  }
})
